<?php

/**
 * This is the model class for table "detail_perjalanan_kereta".
 *
 * The followings are the available columns in table 'detail_perjalanan_kereta':
 * @property integer $ID_DETAIL_KERETA
 * @property integer $ID_PEMBERHENTIAN
 * @property integer $ID_KOTA
 * @property integer $PEM_ID_PEMBERHENTIAN
 * @property integer $ID_KERETA
 * @property integer $KOT_ID_KOTA
 * @property string $TGL_BERANGKAT
 * @property string $TGL_PULANG
 * @property string $JAM_BERANGKAT
 * @property string $JAM_PULANG
 * @property integer $HARGA_TIKET
 * @property integer $DURASI_KERETA
 * @property string $KELAS_KERETA
 * @property string $DESKRIPSI_KERETA
 *
 * The followings are the available model relations:
 * @property Pemberhentian $iDPEMBERHENTIAN
 * @property Kota $kOTIDKOTA
 * @property Kota $iDKOTA
 * @property KeretaApi $iDKERETA
 * @property Pemberhentian $pEMIDPEMBERHENTIAN
 */
class DetailPerjalananKereta extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return DetailPerjalananKereta the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'detail_perjalanan_kereta';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ID_PEMBERHENTIAN, ID_KOTA, PEM_ID_PEMBERHENTIAN, ID_KERETA, KOT_ID_KOTA, HARGA_TIKET, DURASI_KERETA', 'numerical', 'integerOnly'=>true),
			array('KELAS_KERETA', 'length', 'max'=>20),
			array('DESKRIPSI_KERETA', 'length', 'max'=>1500),
			array('TGL_BERANGKAT, TGL_PULANG, JAM_BERANGKAT, JAM_PULANG', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_DETAIL_KERETA, ID_PEMBERHENTIAN, ID_KOTA, PEM_ID_PEMBERHENTIAN, ID_KERETA, KOT_ID_KOTA, TGL_BERANGKAT, TGL_PULANG, JAM_BERANGKAT, JAM_PULANG, HARGA_TIKET, DURASI_KERETA, KELAS_KERETA, DESKRIPSI_KERETA', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'iDPEMBERHENTIAN' => array(self::BELONGS_TO, 'Pemberhentian', 'ID_PEMBERHENTIAN'),
			'kOTIDKOTA' => array(self::BELONGS_TO, 'Kota', 'KOT_ID_KOTA'),
			'iDKOTA' => array(self::BELONGS_TO, 'Kota', 'ID_KOTA'),
			'iDKERETA' => array(self::BELONGS_TO, 'KeretaApi', 'ID_KERETA'),
			'pEMIDPEMBERHENTIAN' => array(self::BELONGS_TO, 'Pemberhentian', 'PEM_ID_PEMBERHENTIAN'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_DETAIL_KERETA' => 'Id Detail Kereta',
			'ID_PEMBERHENTIAN' => 'Id Pemberhentian',
			'ID_KOTA' => 'Id Kota',
			'ID_KOTA' => 'Id Kota',
			'PEM_ID_PEMBERHENTIAN' => 'Pem Id Pemberhentian',
			'ID_KERETA' => 'Id Kereta',
			'KOT_ID_KOTA' => 'Kot Id Kota',
			'TGL_BERANGKAT' => 'Tgl Berangkat',
			'TGL_PULANG' => 'Tgl Tiba',
			'JAM_BERANGKAT' => 'Jam Berangkat',
			'JAM_PULANG' => 'Jam Tiba',
			'HARGA_TIKET' => 'Harga Tiket',
			'DURASI_KERETA' => 'Durasi Kereta',
			'KELAS_KERETA' => 'Kelas Kereta',
			'DESKRIPSI_KERETA' => 'Deskripsi Kereta',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_DETAIL_KERETA',$this->ID_DETAIL_KERETA);
		$criteria->compare('ID_PEMBERHENTIAN',$this->ID_PEMBERHENTIAN);
		$criteria->compare('ID_KOTA',$this->ID_KOTA);
		$criteria->compare('PEM_ID_PEMBERHENTIAN',$this->PEM_ID_PEMBERHENTIAN);
		$criteria->compare('ID_KERETA',$this->ID_KERETA);
		$criteria->compare('KOT_ID_KOTA',$this->KOT_ID_KOTA);
		$criteria->compare('TGL_BERANGKAT',$this->TGL_BERANGKAT,true);
		$criteria->compare('TGL_PULANG',$this->TGL_PULANG,true);
		$criteria->compare('JAM_BERANGKAT',$this->JAM_BERANGKAT,true);
		$criteria->compare('JAM_PULANG',$this->JAM_PULANG,true);
		$criteria->compare('HARGA_TIKET',$this->HARGA_TIKET);
		$criteria->compare('DURASI_KERETA',$this->DURASI_KERETA);
		$criteria->compare('KELAS_KERETA',$this->KELAS_KERETA,true);
		$criteria->compare('DESKRIPSI_KERETA',$this->DESKRIPSI_KERETA,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}